import { ADDTODOLIST, DELETETODOLIST } from "../constant";



const initialState = [
    { id: 1, text: "去买菜" },

]

export function todoApp(state = initialState, action) {
    const { type, data } = action
    switch (type) {
        case ADDTODOLIST:
            return [...state, data]
        // return [data]
        case DELETETODOLIST:
            state = state.filter((e) => {
                return e.id !== data.id
            })
            return [...state]
        default:
            return state
    }
}